<div class="layui-hide-xs">
    <div class="fly-panel fly-column">
        <div class="layui-container">
            <ul class="layui-clear">
                <li class="layui-hide-xs ">
                    <a href="{:url('/index/Index/index')}">首页</a>
                </li>
                <li>
                    <a href="/column/quiz/"> 提问 </a>
                </li>
                <li>
                    <a href="/column/share/"> 分享
                        <span class="layui-badge-dot"></span>
                    </a>
                </li>
                <li>
                    <a href="/column/discuss/"> 讨论 </a>
                </li>
                <li>
                    <a href="/column/suggest/"> 建议 </a>
                </li>
                <li>
                    <a href="/column/notice/"> 公告 </a>
                </li>
                <li>
                    <a href="/column/news/"> 动态 </a>
                </li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                    <span class="fly-mid"></span>
                </li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                    <a href="/user/post/">我发表的贴</a>
                </li>
                <li class="layui-hide-xs layui-hide-sm layui-show-md-inline-block">
                    <a href="/user/post/#collection">我收藏的贴</a>
                </li>
            </ul>
            <div class="fly-column-right layui-hide-xs">
                <span class="fly-search LAY_search">
                    <i class="layui-icon">&#xe615;</i>
                </span>
                <a href="{:url('index/Post/index')}" class="layui-btn">发表新帖</a>
            </div>
            <div class="layui-hide-sm layui-show-xs-block" style="margin-top: -10px; padding-bottom: 10px; text-align: center;">
                <a href="/jie/add/" class="layui-btn">发表新帖</a> 
            </div>
        </div>
    </div>
</div>
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8 content detail">
            <div class="fly-panel detail-box">
                <h1>{:$data['title']}</h1>
                <div class="fly-detail-info">
                    <span class="layui-badge layui-bg-green fly-detail-column">
                        {:$data['cname']}
                    </span>
                    <span class="layui-badge" style="background-color: #999;">
                        <?php 
                            if($data['status']=='1'){echo "已结";}
                            else {echo "未结";}
                         ?>
                    </span>
                    <div class="fly-admin-box" data-id="22385"> </div>
                    <span class="fly-list-nums">
                        <a href="#comment">
                            <i class="iconfont" title="回答">&#xe60c;</i> {:$data['answer_num']}</a>
                        <i class="iconfont" title="人气">&#xe60b;</i> {:$data['view_num']} </span>
                </div>
                <div class="detail-about">
                    <a class="fly-avatar" href="/u/9062424/">
                        <img src="__root__{$data['avatar']}" alt="一号大魔王"> </a>
                    <div class="fly-detail-user">
                        <a href="/u/9062424/" class="fly-link">
                            <cite>{:$data['username']}</cite>
                        </a>
                        <span>{:$data['ctime']} </span>
                    </div>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="22385">
                        <span style="padding-right: 10px; color: #FF7200">悬赏：{:$data['kiss']}飞吻</span>
                        

                        <?php if (session('uid')==$data['uid']): ?>
                           <span class="layui-btn layui-btn-xs jie-admin" type="edit"><a href="{:url('index/Edit/index',['pid'=>$data['pid']])}">编辑此贴</a></span> 
                        <?php endif; ?>

                        <?php if (session('uid')): ?>
                        <span class="layui-btn layui-btn-xs jie-admin " type="collect" data-type="add">收藏</span>
                        <?php endif ?>
                    </div>
                </div>
                <div class="detail-body layui-text photos"> {:$data['content']} </div>
            </div>
            <div class="fly-panel detail-box" id="flyReply">
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>回帖</legend>
                </fieldset>
                <ul class="jieda" id="jieda">
                    <!-- 回复列表-->
                    <?php foreach ($reply as $key => $reply): ?>

                    <li data-id="{$reply['rid']}">
                        <a name="item-1514814975781"></a>
                        <div class="detail-about detail-about-reply">
                            <a class="fly-avatar" href="/u/1259160/">
                                <img src="__root__{:$reply['avatar']}" alt="Pojin"> </a>
                            <div class="fly-detail-user">
                                <a href="/u/1259160/" class="fly-link">
                                    <cite>{$reply['username']}</cite>
                                    <?php if ($reply['level']): ?>
                                    <i class="layui-badge fly-badge-vip">vip{$reply['level']}
                                        <?php endif ?>
                                    </i>
                                </a>
                            </div>
                            <div class="detail-hits">
                                <span>{:ftime($reply['ctime'])} </span>
                            </div>
                            <?php if ($reply['status']==1): ?>
                                <i class="iconfont icon-caina" title="最佳答案"></i>
                            <?php endif ?>


                        </div>
                        <div class="detail-body layui-text jieda-body photos"> {$reply['content']} </div>
                        <div class="jieda-reply">
                            <!-- 点赞按钮 -->
                            <span class="jieda-zan <?php if ($reply['gid']): ?>
                                <?php echo "zanok"; ?>
                            <?php endif ?>" type="zan" rid="{$reply['rid']}">
                                <i class="iconfont icon-zan"></i>
                                <em>{$reply['zan_num']}</em>
                            </span>
                            <!-- 回复按钮 -->
                            <span type="reply"><i class="iconfont icon-svgmoban53"></i> 回复 </span>

                            <?php if ($data['uid']==session('uid')&&$reply['uid']!=session('uid')&&$data['status']==0): ?>
                            <!-- 采纳 -->
                            <div class="jieda-admin"> <span class="jieda-accept" type="accept" rid="{$reply['rid']}" pid="{$data['pid']}"> 采纳 </span> </div>
                            <?php endif ?>

                            
                            


                        </div>
                    </li>


                    <?php endforeach ?>




                </ul>

                <!-- 回帖框 -->
                <div class="layui-form layui-form-pane">
                    <form action="" method="post">
                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block">
                                <textarea id="replyContent" name="" lay-verify="" placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 100px;"></textarea>
                            </div>
                            <div class="layui-form-item">
                                <label for="L_vercode" class="layui-form-label">人类验证</label>
                                <div class="layui-input-inline">
                                    <input type="text" id="L_vercode" name="vercode" required lay-verify="required" placeholder="请回答后面的问题" autocomplete="off"
                                        class="layui-input">
                                </div>
                                <div class="layui-form-mid">
                                    <span style="color: #c00;">
                                        <?php echo $ques; ?>
                                    </span>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <input type="hidden" name="uid" value="{:session('uid')}">
                                <button class="layui-btn" lay-filter="reply" lay-submit>提交回复</button>
                            </div>
                        </div>
                    </form>
                </div>


                <!-- <div style="text-align: center"> </div>
                    <a name="comment"> </a>
                    <blockquote class="layui-elem-quote layui-quote-nm layui-disabled" style="margin: 100px 0 20px; padding: 50px 20px; text-align: center; color: #999!important;">本帖已设置禁止回复</blockquote> -->
            </div>
        </div>
        <div class="layui-col-md4">
            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                <dd>
                    <a href="/jie/22392/">2017 年度 layui 最佳案例 TOP10 已正式出炉</a>
                    <span>
                        <i class="iconfont icon-pinglun1"></i> 3</span>
                </dd>
                <dd>
                    <a href="/jie/22391/">LayIM 年终特惠授权，还可获得 layuiAdmin 立减特权</a>
                    <span>
                        <i class="iconfont icon-pinglun1"></i> 0</span>
                </dd>
            </dl>
            <div class="fly-panel">
                <div class="fly-panel-title"> 心级赞助商
                    <span style="padding: 0 3px;">-</span>
                    <a href="/jie/15697/" class="fly-link fly-joinad    ">我要加入</a>
                </div>
                <div class="fly-panel-main">
                    <a href="http://core.fineui.com/" target="_blank" rel="nofollow" class="fly-zanzhu" style="background-color: #205B95;" time-limit="2018-07-18 0:0:0">FineUI - 9 年控件库 + ASP.NET Core 2.0</a>
                    <a href="http://www.phpyun.com/" target="_blank" rel="nofollow" class="fly-zanzhu" style="background-color: #FF7300" time-limit="2018-04-27 0:0:0">phpyun - 人才招聘系统+商家小程序</a>
                </div>
            </div>
            <div class="fly-panel">
                <div class="fly-panel-title"> 官方产品 </div>
                <div class="fly-panel-main">
                    <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a>
                </div>
            </div>
            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img src="//cdn.layui.com/upload/2017_8/168_1501894831075_19619.jpg" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['layedit', 'form', 'jquery', 'layer', 'element'], function () {
        var layedit = layui.layedit;
        form = layui.form;
        layer = layui.layer;
        $ = layui.jquery;
        element = layui.element;
        replyContent = layedit.build('replyContent', {
            tool: [
                'strong' //加粗
                , 'italic' //斜体
                , 'underline' //下划线
                , 'del' //删除线 
                , '|' //分割线        
                , 'left' //左对齐
                , 'center' //居中对齐
                , 'right' //右对齐
                , 'link' //超链接
                , 'unlink' //清除链接
                , 'face' //表情
                // ,'image' //插入图片
                // ,'help' //帮助
            ]
        }); //建立编辑器



        form.on('submit(reply)', function (data) {
            data.field.content = layedit.getContent(replyContent);
            // console.log(data);
            // alert('message')
            data.field.pid = {:$data['pid']};
            $.ajax({
                url: '{:url('index/Read/reply')}',
                type: 'POST',
                dataType: 'json',
                data: data.field,
            })
                .done(function (res) {
                    if (res.error == 1) {
                        layer.msg(res.info, { icon: 5 });
                    } else {
                        layer.msg(res.info, { icon: 6 }, function () {
                            location.href = res.url;
                        });
                    }
                })
                .fail(function () {
                    console.log("error");
                })
            return false;
        });

        // 赞
        $(".jieda-zan").click(function(event) {
            if (!{:session('uid')}) {layer.msg("未登录,请登录后重试")}
            else{
                uid={:session('uid')};
                rid = $(this).attr('rid');
                zan_num = $(this).find('em').text();
                that = $(this);
                $.ajax({
                    url: '{:url('index/Read/good')}',
                    type: 'POST',
                    dataType: 'json',
                    data: {rid: rid,uid:uid},
                })
                .done(function(res) {
                    if(res.error==1){
                    that.removeClass('zanok');
                    that.find('em').text(zan_num-1);
                    }else{
                    that.addClass('zanok');
                    that.find('em').text(parseInt(zan_num)+1);
                    }
                })
                .fail(function() {
                    layer.msg("系统异常，请稍后再试", function(){
                    });
                });
            }
            
        });
        //回复采纳
        $(".jieda-accept").click(function(){
            // uid = {:session('uid')};
            rid = $(this).attr('rid');
            pid = $(this).attr('pid');
            that = $(this);
            $.ajax({
                url: '{:url('index/Read/accept')}',
                type: 'POST',
                dataType: 'json',
                data: {rid:rid,pid:pid},
            })
            .done(function(res) {
                if (res.error==0) {
                    layer.msg(res.info, { icon: 6 }, function () {
                            location.href = res.url;
                        });
                };
            })
            .fail(function() {
                layer.msg("系统异常，请稍后再试", function(){
                    });
            });
            
        });
        

    });
</script>